/******分类页商品数量加减****/
function modifyBuyNum(d, a) {
	var b;
    var c;
   if (a == -1) {
        c = $(d).parents(".shopping_num").find("input");
        b = parseInt(c.val()) || 1;
        if (b == 1) {
            return
        } else {
            if (b == 2) {
                $(d).attr("class", "p-reduce disable")
            } else {
                $(d).prev().attr("class", "add")
            }
            c.val(b + a)
        }
    } else {
        c = $(d).parents(".shopping_num").find("input");
        var max = c.attr('data-max');
        b = parseInt(c.val()) || 1;
        if(b+a > max){
        	alert('库存不足');
        	return;
        }
        $(d).next().attr("class", "p-reduce")
      	c.val(b + a)
    }		
}
	
function checkBuyNum(d) {
	var c = $(d);
	var num = parseInt(c.val());
	if($.isNumeric(num) && num >= 1)
	{
		var b = c.next().find("a");
		var max = parseInt(c.attr('data-max'));
		if (num>max){
			alert('库存不足');
			c.val(max);
			b.attr("class", "add");
            b.next().attr("class", "decrease");
		}
		else if (c.val() == 1) {
            b.attr("class", "add");
            b.next().attr("class", "dis_decrease");
        } 
		else if(c.val() > 1)
		{
			 b.attr("class", "add");
             b.next().attr("class", "decrease");
		}
	}
	else
	{
		alert("请输入正确的商品数量");
		c.val(1);
	}
}

$(function(){
	$(".catitem h3").on("click",function(){
		$(this).parent().addClass("curr").siblings().removeClass("curr");	
	});
	$(".list-all li").hover(function(){
		$(this).addClass("curr");
	},function(){
		$(this).removeClass("curr");
	});
})